package com.jic.market.impl;

import java.lang.Long;
import java.util.List;

import com.jic.market.entity.LotteryReceiver;
import com.jic.market.mapper.LotteryReceiverMapper;
import com.jic.market.service.LotteryReceiverService;
import com.jic.common.base.vo.Page;
import com.jic.common.base.vo.PageResult;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 抽奖活动用户信息表
 * @author : 
 * @email : 
 * @since : 2020-03-03 03:06:39
 * @version : v1.0.0
 */
@Service
public class LotteryReceiverServiceImpl implements LotteryReceiverService{

    @Autowired
    private LotteryReceiverMapper lotteryReceiverMapper;

    @Override
    public long insert(LotteryReceiver lotteryReceiver) {
        long flag = lotteryReceiverMapper.insert(lotteryReceiver);
        return flag;
    }

    @Override
    public long delete(Long id) {
        return lotteryReceiverMapper.delete(id);
    }

    @Override
    public long update(LotteryReceiver lotteryReceiver) {
        return lotteryReceiverMapper.update(lotteryReceiver);
    }

    @Override
    public LotteryReceiver queryByPrimaryKey(Long id){
        return lotteryReceiverMapper.queryByPrimaryKey(id);
    }

    @Override
    public List<LotteryReceiver> query(LotteryReceiver lotteryReceiver){
        return lotteryReceiverMapper.query(lotteryReceiver);
    }

    @Override
    public PageResult<LotteryReceiver> queryPage(LotteryReceiver lotteryReceiver, Page pageQuery) {
        //计算下标
        int startIndex = (pageQuery.getStart() - 1) * pageQuery.getLimit();
        List<LotteryReceiver> list = lotteryReceiverMapper.queryPage(startIndex, pageQuery.getLimit(), lotteryReceiver);
        long count = lotteryReceiverMapper.queryPageCount(lotteryReceiver);
        PageResult pageResult = new PageResult();
        pageResult.setRows(list);
        pageResult.setTotal(count);
        return pageResult;
    }
}